<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:hmrTable="http://java.sun.com/jsf/composite/table"
	xmlns:hmrDetail="http://java.sun.com/jsf/composite/detail">

<cc:interface>
	<cc:attribute name="handler"				type="com.hemerasolutions.v2trainer.component.interfaces.list.StepListCompInterface" />
	<cc:attribute name="isTrainingSystem"		type="java.lang.Boolean"	default="false"	required="false" />
	<cc:attribute name="enabled" 				type="java.lang.Boolean"	default="true" 	required="true"  />
	<cc:attribute  name="onIzPopUp"				type="java.lang.String" 	default=""		required="false"/>
	<cc:attribute  name="onImzPopUp"			type="java.lang.String" 	default="" 		required="false"/>
	<cc:attribute  name="onStatistiUPopUp"		type="java.lang.String" 	default="" 		required="false"/>
	
</cc:interface>


<cc:implementation>

	<span id="#{cc.clientId}" class="workoutComposite" style="border:none" >
		<p:panel  id="workoutpanel"  style="border:none" styleClass="ui-training" rendered="#{cc.attrs.handler.stepLevel != null}"     >
			<h:outputScript library="js" name="training.js" rendered="#{cc.attrs.enabled}" />	
			<h:outputText value="root" 						style="display:none" styleClass="ui-step-counter" />
			<h:outputText value="#{cc.attrs.handler.stepLevel.rootStep.uuid}"	style="display:none" styleClass="ui-step-uuid" />

			<h:panelGrid id="steptable" styleClass="ui-sortable-custom ui-workout-root">
				<h:column>
					<c:forEach  items="#{cc.attrs.handler.stepLevel.rootStep.steps}"  var="step" varStatus="loop"   >
						<p:outputPanel id="step#{step.uuid}"  layout="block" styleClass="ui-stepPanel">
							<hmrDetail:stepComp  handler="#{cc.attrs.handler.stepHandlers[step.uuid]}"	stepType="#{step.type}" editable="#{cc.attrs.enabled}"
									onIzPopUp="#{cc.attrs.onIzPopUp}"	onImzPopUp="#{cc.attrs.onImzPopUp}" update="#{cc.clientId}"    /> 
						
						</p:outputPanel>							
					</c:forEach>				
				</h:column>		
			</h:panelGrid>

			

			<h:panelGrid  columns="2" columnClasses="top-align,top-align"  >
				<p:panel  style="width:150px;height:150px;white-space:normal;word-wrap: break-word;overflow-y:auto;" styleClass="ui-trainingStatistics"   >
					<h:outputText value="#{cc.attrs.handler.stepLevel.rootStep.stepTranslated}" style="white-space:normal;word-wrap: break-word;" />
				</p:panel>
				<p:outputPanel  styleClass="ui-trainingStatistics"  >
					<c:if test="#{not cc.attrs.isTrainingSystem}">
						<hmrTable:statisticTable handler="#{cc.attrs.handler.statisticTable}"
												 onStatistiUPopUp="#{cc.attrs.onStatistiUPopUp}"  />
					</c:if>
				</p:outputPanel>
			
			</h:panelGrid>

		</p:panel>		
		<p:remoteCommand  name="tSChanged_#{cc.clientId.replaceAll('-|:','_')}" actionListener="#{cc.attrs.handler.trainingStepChanged}" 
			process="@this"  update="@form, :growl"  />			
	</span>
</cc:implementation>


</html>